package com.seednia.module.core.xport;

import java.io.InputStream;
import java.util.Map;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;

/**
 * 
 * @author Young Suk Ahn
 *
 */
public class ImporterXml extends AbstractImporter  {

	public static final String FORMAT = "xml";
	
	public ImporterXml()
	{
		super.setFormat(FORMAT);
	}
	
	/**
	 * Jaxb Unmarshalling
	 * @param is
	 * @return
	 * @throws JAXBException
	 */
	public XportDataContainer importFrom(InputStream is, Map<String, Object> params) throws Exception
	{
		// === Unmarshaling ===
		// xmlfilename contains the XML document of an individual
		JAXBContext context = JAXBContext.newInstance(getXportingTypes());
		Unmarshaller umarshaller = context.createUnmarshaller();
		XportDataContainer retval = (XportDataContainer)umarshaller.unmarshal(is);
		return retval;
	}

}
